<?php
//日期相差
function maketime($date)
{
    list($year,$month,$day) = explode("-",$date);
    return mktime(0,0,0,$month,$day,$year);
}

$date1 = "2015-01-01";
$date2 = "2015-01-05";
$d = (maketime($date2) - maketime($date1)) / (3600*24);
echo "$date1 - $date2<br /> 相差 $d 天";